package com.service.generic_service;

import com.mapper.UserMapper;
import com.pojo.User;
import com.service.iter.generic_service.ILoginService;
import com.util.Res;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Objects;

/**
 * 登录服务impl
 *
 * @author admin
 * @date 2023/06/19
 */
@Service
@Transactional
public class LoginServiceImpl implements ILoginService {
    /**
     * 用户映射器
     */
    @Autowired
    private UserMapper userMapper;

    /**
     * 为空
     *
     * @param user 用户
     * @return {@link Res}
     */
    public Res isNull(User user) {
        Res res = new Res();

        System.out.println(user);
        User aNull = userMapper.isNull(user);
        if (Objects.isNull(aNull)) {
            res.setMsg("账号/密码错误");
            res.setCode(400);
        } else {

            res.setCode(200);
            res.setData(aNull);
        }
        return res;
    }
}
